﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once
#include "GcmpGeometryInterface.h"
#include "Vector3d.h"

namespace gcmp
{
    class Vector3d;
    class ICurve2d;
    class IPolygon;
    class IBody;

    /// \brief 几何对象极值点计算类，用于计算几何对象的极值点
    ///
    class GCMP_GEOMETRY_INTERFACE_EXPORT AlgorithmExtremum
    {    
    public:
        /// \brief  计算二维曲线在指定方向上的极值点
        /// \param pCurve2d                  二维曲线
        /// \param unitDirection             二维单位向量
        /// \param minimalPointt             最小值点
        /// \param maximalPoint              最大值点
        /// \return   成功返回True，失败返回False
        static bool Calculate(const ICurve2d *pCurve2d, const Vector2d &unitDirection, Vector2d &minimalPoint, Vector2d &maximalPoint);

        /// \brief  计算多边形在指定方向上的极值点
        /// \param pPolygon                  多边形
        /// \param unitDirection             二维单位向量
        /// \param minimalPoint              最小值点
        /// \param maximalPoint              最大值点
        /// \return   成功返回True，失败返回False
        static bool Calculate(const IPolygon *pPolygon, const Vector2d &unitDirection, Vector2d &minimalPoint, Vector2d &maximalPoint);

        /// \brief  计算体在指定方向上的极值点
        /// \param pBody                     体
        /// \param unitDirection             三维单位向量
        /// \param minimalPoint              最小值点
        /// \param maximalPoint              最大值点
        /// \return   成功返回True，失败返回False
        static bool Calculate(const IBody *pBody, const Vector3d &unitDirection, Vector3d &minimalPoint, Vector3d &maximalPoint);
    };
}



